local GameDB = import(".GameDB")
-- 核心属性
function GameDB:queryCorePorpValue(job, tp, level)
    local t = {}
    local r = self:getCachedValue("coreProp", function(r)
        if tonumber(r.class) == job and tonumber(r.type) == tp and tonumber(r.level) == level then
            t = {
                {tp = tonumber(r.addType1), value = tonumber(r.addNum1)},
                {tp = tonumber(r.addType2), value = tonumber(r.addNum2)},
                {tp = tonumber(r.addType3), value = tonumber(r.addNum3)},
            }
            return true
        end
    end)
    return t
end
-- 根据总点数 查找 
function GameDB:queryCorePorpAddPointCostBySumPoint(sumPoint)
    local t = self:getCachedValues("corePropLevel", nil, function(a, b)
        return tonumber(a.lvupMax) < tonumber(b.lvupMax) 
    end)

    for k ,v in ipairs(t) do
        if tonumber(v.lvupMax) > sumPoint then
            return tonumber(v.num)
        end
    end
    return tonumber(t[#t].num)
end

function GameDB:getMaxSumPoint(sumPoint)
    local t = self:getCachedValues("corePropLevel", nil, function(a, b)
        return tonumber(a.lvupMax) < tonumber(b.lvupMax) 
    end)
    return tonumber(t[#t].lvupMax)
end


-- 核心属性
function GameDB:queryCorePorpExtraValues(job)
    local t = {}
    local rows = self:getCachedValues("corePropExtra", function(r)
        return tonumber(r.class) == job
    end, function(a, b)
        local aStar = tonumber(a.starNum) or 0
        local bStar = tonumber(b.starNum) or 0
        return aStar < bStar
    end)
    return rows
end
